package com.rd.sys.dto.commmon.enums;

import java.util.HashMap;
import java.util.Map;

import baseproj.common.constants.BaseEnum;
import baseproj.inter.Message;

public class NodeInfoEnum {

    /**
     * 节点类型.
     */
    public enum NodeType implements BaseEnum {

        /** 业务处理机. */
        SERVER("1", Message.getMessage("sys.sysnode.nodetype.server")),

        /** 异步数据库. */
        DATABASE("2", Message.getMessage("sys.sysnode.nodetype.database")),

        /** AMI OP门户. */
        OP("3", Message.getMessage("sys.sysnode.nodetype.op")),

        /** REST接口机. */
        REST("4", Message.getMessage("sys.sysnode.nodetype.rest")),

        /** BSS接口机. */
        BSS("5", Message.getMessage("sys.sysnode.nodetype.bss"));

        /** The code. */
        public String code;

        /** The name. */
        public String name;

        /** The code map. */
        public static Map<String, String> codeMap = new HashMap<String, String>();

        /**
         * Instantiates a new node type.
         * 
         * @param code
         *            the code
         * @param name
         *            the name
         */
        NodeType(String code, String name) {
            this.code = code;
            this.name = name;
        }

        static {
            for (int i = 0; i < values().length; i++) {
                codeMap.put(values()[i].code, values()[i].name);
            }
        }

        /**
         * Equals.
         * 
         * @param value
         *            the value
         * @return true, if successful
         * @version
         */
        public boolean equals(String value) {
            return this.code.equals(value);
        }

        /**
         * Gets the code.
         * 
         * @return the code
         */
        @Override
        public String getCode() {
            return code;
        }

        /**
         * Gets the name.
         * 
         * @return the name
         */
        @Override
        public String getName() {
            return name;
        }

    }

    /**
     * 节点编号范围.
     */
    public enum NodeNoRange implements BaseEnum {

        /** 业务处理机最小节点编号. */
        SERVERNODEMIN("1", "1"),

        /** 业务处理机最大节点编号. */
        SERVERNODEMAX("50", "50"),

        /** 异步数据库最小节点编号. */
        DATABASENODEMIN("51", "51"),

        /** 异步数据库最大节点编号. */
        DATABASENODEMAX("100", "100"),

        /** 门户最小节点编号. */
        OPNODEMIN("101", "101"),

        /** 门户最大节点编号. */
        OPNODEMAX("150", "150"),

        /** REST接口机最小节点编号. */
        RESTNODEMIN("151", "151"),

        /** REST接口机最大节点编号. */
        RESTNODEMAX("160", "160"),

        /** BSS接口机最小节点编号. */
        BSSNODEMIN("161", "161"),

        /** BSS接口机最大节点编号. */
        BSSNODEMAX("170", "170");

        /** The code. */
        public String code;

        /** The name. */
        public String name;

        /** The code map. */
        public static Map<String, String> codeMap = new HashMap<String, String>();

        /**
         * Instantiates a new node no range.
         * 
         * @param code
         *            the code
         * @param name
         *            the name
         */
        NodeNoRange(String code, String name) {
            this.code = code;
            this.name = name;
        }

        static {
            for (int i = 0; i < values().length; i++) {
                codeMap.put(values()[i].code, values()[i].name);
            }
        }

        /**
         * Equals.
         * 
         * @param value
         *            the value
         * @return true, if successful
         * @version
         */
        public boolean equals(String value) {
            return this.code.equals(value);
        }

        /**
         * Gets the code.
         * 
         * @return the code
         */
        @Override
        public String getCode() {
            return code;
        }

        /**
         * Gets the name.
         * 
         * @return the name
         */
        @Override
        public String getName() {
            return name;
        }

    }

    /**
     * 节点端口范围.
     */
    public enum NodePortRange implements BaseEnum {

        /** 最小端口号. */
        MinPort("0", "0"),

        /** 最大端口号. */
        MaxPort("65535", "65535");

        /** The code. */
        public String code;

        /** The name. */
        public String name;

        /** The code map. */
        public static Map<String, String> codeMap = new HashMap<String, String>();

        /**
         * Instantiates a new node port range.
         * 
         * @param code
         *            the code
         * @param name
         *            the name
         */
        NodePortRange(String code, String name) {
            this.code = code;
            this.name = name;
        }

        static {
            for (int i = 0; i < values().length; i++) {
                codeMap.put(values()[i].code, values()[i].name);
            }
        }

        /**
         * Equals.
         * 
         * @param value
         *            the value
         * @return true, if successful
         * @version
         */
        public boolean equals(String value) {
            return this.code.equals(value);
        }

        /**
         * Gets the code.
         * 
         * @return the code
         */
        @Override
        public String getCode() {
            return code;
        }

        /**
         * Gets the name.
         * 
         * @return the name
         */
        @Override
        public String getName() {
            return name;
        }

    }

    /**
     * 节点同步结果.
     */
    public enum NodeSyncResult implements BaseEnum {

        /** 成功. */
        SUCC("0", Message.getMessage("common.log.success")),

        /** 失败. */
        FAIL("1", Message.getMessage("common.log.fail"));

        /** The code. */
        public String code;

        /** The name. */
        public String name;

        /** The code map. */
        public static Map<String, String> codeMap = new HashMap<String, String>();

        /**
         * Instantiates a new node sync result.
         * 
         * @param code
         *            the code
         * @param name
         *            the name
         */
        NodeSyncResult(String code, String name) {
            this.code = code;
            this.name = name;
        }

        static {
            for (int i = 0; i < values().length; i++) {
                codeMap.put(values()[i].code, values()[i].name);
            }
        }

        /**
         * Equals.
         * 
         * @param value
         *            the value
         * @return true, if successful
         * @version
         */
        public boolean equals(String value) {
            return this.code.equals(value);
        }

        /**
         * Gets the code.
         * 
         * @return the code
         */
        @Override
        public String getCode() {
            return code;
        }

        /**
         * Gets the name.
         * 
         * @return the name
         */
        @Override
        public String getName() {
            return name;
        }

    }

    /**
     * Checks if is web node.
     * 
     * @param value
     *            the value
     * @return true, if is web node
     */
    public static boolean isWebNode(String value) {
        return NodeType.OP.getCode().equals(value);
    }
}
